Remove need for python, simplify range functionality #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This rewrites a bunch of stuff in order not to use python. It also removes the need to get the visual selection.
For the first part, url encoding is easily implementable in Vim. Apparently. I'll be honest, I'm not entirely sure why the
s:url_encode
function works, but it seems to work quite well.The other reason to use python, though, is the cross-platform
webbrowser.open
. Vim has nothing like that, but a simple replacement is easy to whip up, as you can see in thes:open_url
function. Sadly, this doesn't work on Windows, since I don't know how to open urls on Windows. I'm sure there's an easy way using the "start" command, I just don't know it. I'm also not sure how robust relying onxdg-open
is, but I'm thinking it would be quite easy to add replacements, likegnome-open
or whatever if people complain.These are drawbacks, but the benefit is that you don't need to
sleep 500m
, and you don't get weird messages due to python stdout.As for the visual selection, I've removed the need for it, since
-range=%
provides the ability to take the start and end lines of the selection, defaulting to the start and end lines of the entire buffer. It seems very unlikely to me that someone would actually like to share only half of the first line of a piece of code and/or half of the last one. If nothing else, it might mess with indentation. Seems reasonable to assume that people would like to share a set of lines, and not a random selection.Given that this pull request improves some things and makes some things worse, I would definitely understand if you reject it. Or, if you want, I could implement only those changes you'd rather have.